using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Threading;

namespace Biolink.Common.Remoting.Extensions
{
    public static class TrafficDefaultInfo
    {
        public static readonly TrafficStatistic Statistic = new TrafficStatistic();

        static TrafficDefaultInfo()
        {
            TrafficStatisticConfiguration.Common.Update += Update;
            TrafficStatisticConfiguration.Common.UpdateTotal += UpdateTotal;
        }

        public static void Bind()
        {
        }

        private static void UpdateTotal(int requests, long sent, long recieved)
        {
            lock(Statistic)
            {
                Statistic.Total.Requests += requests;
                Statistic.Total.Sent += sent;
                Statistic.Total.Recieved += recieved;
            }
            
        }

        private static void Update(string @class, string method, long sent, long recieved)
        {
            Statistic.Add(@class, method, sent, recieved);
        }


    }
}